import React from 'react'

import Constants from '../../common/Constants'
import ResponseConstants from '../../common/ResponseConstants'
import BaseAction from '../common/BaseAction'
import ToastUtils from '../../common/ToastUtils'

export default class HeartLoveRquestCreateSelfDataAction extends BaseAction {
  constructor(props) {
    super(props)

    this.moduleType = Constants.MODULE_TYPE.HEART
    this.name = 'HeartLoveRquestCreateSelfDataAction'
  }

  _dealCall(caller, data) {
    caller.setState({
      viewStatus: 1
    })
  }

  finish(data, isSucceed, response) {
    console.log('HeartLoveRquestCreateSelfDataAction-', data, isSucceed, response)
    let detail = ''
    if (response.status == ResponseConstants.status_created_success) {
      detail = '提交成功'
    } else if (response.status == ResponseConstants.status_unauthorized) {
      detail = data.detail ? data.detail : '登录已过期'
    } else if (response.status == ResponseConstants.status_server_error) {
      detail = '服务器出错'
    } else {
      // detail = data.detail ? data.detail : "未知错误";
      detail = '数据出错'
    }
    ToastUtils.show(detail)
    this.caller.setState({
      viewStatus: response.status,
      statusText: detail,
      commitDataFinish: true
    })
  }
}
